/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Code;




import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.scene.Node;
import com.jme3.terrain.geomipmap.TerrainQuad;

/**
 *
 * @author Owner
*/
public class Physics {
    public BulletAppState bulletAppState;
    public void initialize(){
    bulletAppState = new BulletAppState();

    }
    public void loadTerrainCollision(TerrainQuad terrain){
        CollisionShape terrainShape = CollisionShapeFactory.createMeshShape((Node) terrain);
        RigidBodyControl landscape = new RigidBodyControl(terrainShape, 0);
        terrain.addControl(landscape);
        bulletAppState.getPhysicsSpace().add(terrain);
    }
    public void loadCharacterCollision(Character character){
        CapsuleCollisionShape characterShape = new CapsuleCollisionShape(1.7f, 2f, 1);
        //0.8f,6f,1
        character.characterController = new CharacterControl(characterShape, 20);
        character.player.addControl(character.characterController);
        bulletAppState.getPhysicsSpace().add(character.characterController);
        character.characterController.setJumpSpeed(20f);
        character.characterController.setFallSpeed(0.1f);
    }
}

